home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.Form frmMeal
- Caption = "Nutrition in a Meal"
- ClientHeight = 3828
- ClientLeft = 1068
- ClientTop = 1548
- ClientWidth = 5112
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 7.8
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- LinkTopic = "Form1"
- PaletteMode = 1 'UseZOrder
- ScaleHeight = 3828
- ScaleWidth = 5112
- Begin VB.TextBox txtQnty
- Height = 285
- Index = 9
- Left = 2280
- TabIndex = 22
- Top = 3480
- Width = 495
- End
- Begin VB.TextBox txtQnty
- Height = 285
- Index = 8
- Left = 2280
- TabIndex = 21
- Top = 3120
- Width = 495
- End
- Begin VB.TextBox txtQnty
- Height = 285
- Index = 7
- Left = 2280
- TabIndex = 20
- Top = 2760
- Width = 495
- End
- Begin VB.TextBox txtQnty
- Height = 285
- Index = 6
- Left = 2280
- TabIndex = 19
- Top = 2400
- Width = 495
- End
- Begin VB.TextBox txtQnty
- Height = 285
- Index = 5
- Left = 2280
- TabIndex = 18
- Top = 2040
- Width = 495
- End
- Begin VB.TextBox txtQnty
- Height = 285
- Index = 4
- Left = 2280
- TabIndex = 17
- Top = 1680
- Width = 495
- End
- Begin VB.TextBox txtQnty
- Height = 285
- Index = 3
- Left = 2280
- TabIndex = 16
- Top = 1320
- Width = 495
- End
- Begin VB.TextBox txtQnty
- Height = 285
- Index = 2
- Left = 2280
- TabIndex = 15
- Top = 960
- Width = 495
- End
- Begin VB.TextBox txtQnty
- Height = 285
- Index = 1
- Left = 2280
- TabIndex = 14
- Top = 600
- Width = 495
- End
- Begin VB.PictureBox picAnalysis
- Height = 2055
- Left = 2880
- ScaleHeight = 2004
- ScaleWidth = 2124
- TabIndex = 1
- Top = 1200
- Width = 2175
- End
- Begin VB.CommandButton cmdAnalyze
- Caption = "Analyze Meal Nutrition"
- Height = 375
- Left = 2880
- TabIndex = 0
- Top = 720
- Width = 2175
- End
- Begin VB.TextBox txtQnty
- Height = 285
- Index = 0
- Left = 2280
- TabIndex = 4
- Top = 240
- Width = 495
- End
- Begin VB.Label lblFood
- Alignment = 1 'Right Justify
- Caption = "(food name)"
- Height = 255
- Index = 9
- Left = 0
- TabIndex = 13
- Top = 3480
- Width = 2175
- End
- Begin VB.Label lblFood
- Alignment = 1 'Right Justify
- Caption = "(food name)"
- Height = 255
- Index = 8
- Left = 0
- TabIndex = 12
- Top = 3120
- Width = 2175
- End
- Begin VB.Label lblFood
- Alignment = 1 'Right Justify
- Caption = "(food name)"
- Height = 255
- Index = 7
- Left = 0
- TabIndex = 11
- Top = 2760
- Width = 2175
- End
- Begin VB.Label lblFood
- Alignment = 1 'Right Justify
- Caption = "(food name)"
- Height = 255
- Index = 6
- Left = 0
- TabIndex = 10
- Top = 2400
- Width = 2175
- End
- Begin VB.Label lblFood
- Alignment = 1 'Right Justify
- Caption = "(food name)"
- Height = 255
- Index = 5
- Left = 0
- TabIndex = 9
- Top = 2040
- Width = 2175
- End
- Begin VB.Label lblFood
- Alignment = 1 'Right Justify
- Caption = "(food name)"
- Height = 255
- Index = 4
- Left = 0
- TabIndex = 8
- Top = 1680
- Width = 2175
- End
- Begin VB.Label lblFood
- Alignment = 1 'Right Justify
- Caption = "(food name)"
- Height = 255
- Index = 3
- Left = 0
- TabIndex = 7
- Top = 1320
- Width = 2175
- End
- Begin VB.Label lblFood
- Alignment = 1 'Right Justify
- Caption = "(food name)"
- Height = 255
- Index = 2
- Left = 0
- TabIndex = 6
- Top = 960
- Width = 2175
- End
- Begin VB.Label lblFood
- Alignment = 1 'Right Justify
- Caption = "(food name)"
- Height = 255
- Index = 1
- Left = 0
- TabIndex = 5
- Top = 600
- Width = 2175
- End
- Begin VB.Label lblQnty
- Caption = "Quantity in Meal"
- Height = 255
- Left = 2040
- TabIndex = 2
- Top = 0
- Width = 1455
- End
- Begin VB.Label lblFood
- Alignment = 1 'Right Justify
- Caption = "(food name)"
- Height = 255
- Index = 0
- Left = 0
- TabIndex = 3
- Top = 240
- Width = 2175
- End
- Attribute VB_Name = "frmMeal"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Dim nutName(1 To 5) As String 'nutrient names
- Dim nutTable(1 To 10, 1 To 5) As Single 'nutrient values for each food
- Private Sub cmdAnalyze_Click()
- 'Determine the nutritional content of a meal
- Dim quantity(1 To 10) As Single 'amount of food in meal
- Call GetAmounts(quantity())
- Call ShowData(quantity())
- End Sub
- Private Sub Form_Load()
- Dim i As Integer, j As Integer, foodName As String
- 'Fill arrays; assign label captions
- Open App.Path & "\NUTTABLE.TXT" For Input As #1
- For i = 1 To 5
- Input #1, nutName(i)
- Next i
- For i = 1 To 10
- Input #1, foodName
- lblFood(i - 1).Caption = foodName
- For j = 1 To 5
- Input #1, nutTable(i, j)
- Next j
- Next i
- Close #1
- End Sub
- Private Sub GetAmounts(quantity() As Single)
- Dim i As Integer
- 'Obtain quantities of foods consumed
- For i = 1 To 10
- quantity(i) = Val(txtQnty(i - 1).Text)
- Next i
- End Sub
- Private Sub ShowData(quantity() As Single)
- Dim col As Integer, row As Integer
- Dim amount As Single, nutWid As Single
- 'Display amount of each component
- picAnalysis.Cls
- picAnalysis.Print "This meal contains the"
- picAnalysis.Print "following quantities"
- picAnalysis.Print "of these nutritional"
- picAnalysis.Print "components:"
- picAnalysis.Print
- For col = 1 To 5
- amount = 0
- For row = 1 To 10
- amount = amount + quantity(row) * nutTable(row, col)
- Next row
- picAnalysis.Print nutName(col) & ":"; Tab(16); amount
- Next col
- End Sub
-